home *** CD-ROM | disk | FTP | other *** search
- #include <dos.h>
- #include <conio.h>
- #include <stdio.h>
- #include <memory.h>
- #include <malloc.h>
- #include "xmsstuff.h"
-
- main()
- {
- char _far *temp;
- unsigned int handle;
- unsigned int memavail;
- unsigned int a;
- unsigned char _far *dataptr;
- int off;
-
- if( XMS_detect() )
- printf( "XMS drive found.\n");
- else
- printf( "XMS driver not found.\n");
- XMS_ini();
- printf( "XMS Version Number = %u.\n", XMSVersion );
- printf( "Largest XMS memory block = %uKb\n", XMS_largestavail());
- memavail = XMS_memavail();
- printf( "Total free XMS memory = %uKb\n", memavail);
- if( memavail < 64 )
- {
- printf( "not enough memory to continue test.\n" );
- }
- printf( "allocating 64Kb\n");
- handle = XMS_allocate_block( 64 );
- if( handle == 255 )
- {
- printf( "XMS allocation failed. error = %d\n", error);
- exit( 1 );
- }
- printf( "XMS allocation sucsessful: handle = %u\n", handle );
- printf( "Total free XMS handles = %u\n",XMS_handles_free( handle ) );
- memavail = XMS_memavail();
- printf( "Total free XMS memory = %uKb\n", memavail);
- printf( "Begining to transfer data to XMS.\n");
-
- if( (dataptr = (char far *)_fmalloc( (size_t)64000)) == NULL )
- {
- printf( "Insuffent conventional memory available.\n");
- exit( 1 );
- }
-
- for( a = 0; a < 64000; a ++ )
- dataptr[a] = a % 4;
-
- if( !XMSE_con_to_xms( handle, dataptr, (unsigned int)64000 ) )
- {
- printf( "XMS Move failed. Your in trouble now!!\n");
- exit( 1 );
- }
- else
- printf( "XMS Move sucsessful.\n");
-
- printf( "Clearing memory.\n");
- for( a = 0; a < 64000; a ++ )
- dataptr[a] = 0;
-
- printf( "Attempting to lock XMS memory.\n");
- if( (temp = XMS_lock_block( handle )) == NULL )
- {
- printf( "Could not lock XMS handle.\n" );
- exit ( 0 );
- }
- printf( "XMS handle locked. Ptr = %pH \n", temp );
- printf( "Enabling A20 line.\n" );
-
- if( !XMS_enable_A20() )
- {
- printf( "Could not enable A20.\n");
- exit( 0 );
- }
- printf( "Enabled A20.\n");
- printf( "Disabling A20 line.\n" );
- if( !XMS_disable_A20() )
- {
- printf( "Could not disable A20.\n");
- exit( 0 );
- }
- printf( "Disabled A20.\n");
-
- if( !XMS_unlock_block( handle ) )
- {
- printf( "Could not unlock XMS handle.\n" );
- exit ( 0 );
- }
- printf( "XMS handle unlocked.\n" );
-
-
- if( !XMSE_xms_to_con( handle, dataptr, (unsigned int)64000 ) )
- {
- printf( "XMS Move failed. Your in trouble now!!\n");
- exit( 1 );
- }
- else
- printf( "XMS Move sucsessful.\n");
-
- off = 0;
- for( a = 0; a < 64000; a ++ )
- if( dataptr[a] != a % 4 )
- {
- off ++;
- printf( "Block %d doesn't match.\n", a);
- }
-
- printf( "%u nonmatching entries found.\n", off );
-
- if( XMS_free_block( handle ) )
- printf( "XMS free_block sucsessful.\n");
- else
- {
- printf( "XMS free_block not sucsessful. error = %d\n", error );
- exit( 1 );
- }
-
- _ffree( dataptr );
- exit ( 0 );
- }
-
-
-
-
-